﻿using System;
using System.Globalization;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace HOG.Controls
{
    public partial class LanguageControl : UserControl
    {
        public LanguageControl()
        {
            InitializeComponent();
            Polska.MouseLeftButtonDown += new MouseButtonEventHandler(languageChange);
            WBrytania.MouseLeftButtonDown += new MouseButtonEventHandler(languageChange);
        }
        private void languageChange(CultureInfo cultureInfo)
        {
            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
            if (Close != null)
                Close(null, null);
        }
        private void languageChange(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement senderWithName = sender as FrameworkElement;
            if (senderWithName.Name == "WBrytania")
                languageChange(new CultureInfo("en-GB"));
            else
                languageChange(new CultureInfo("pl-PL"));
        }
        public EventHandler Close;
    }
}
